package hibernate.fileControler;

import java.io.File;

public class ListFiles {
	 public static boolean checkFile(String path, String name) throws MyException{
		 File folder = new File(path);
		 File[] listOfFiles = folder.listFiles(); 
		 
		 for (int i = 0; i < listOfFiles.length; i++){			 
			  if (listOfFiles[i].isFile()){
				  if(listOfFiles[i].getName().toLowerCase().indexOf(name) >= 0){
					  System.out.println("dosya : "+listOfFiles[i].getName());
					  throw new MyException("Dosya zaten mevcut");
				  }
			  }
		 }
		 return true;
	 }
	 public static boolean checkFile4Cancel(String path, String name) throws MyException{
		 File folder = new File(path);
		 File[] listOfFiles = folder.listFiles(); 
		 
		 for (int i = 0; i < listOfFiles.length; i++){			 
			  if (listOfFiles[i].isFile()){
				  if(listOfFiles[i].getName().toLowerCase().indexOf(name) >= 0){
					  System.out.println("dosya : "+listOfFiles[i].getName());
					  return true;
				  }
			  }
		 }
		 return false;
	 }
}